const sys = require(`./system.js`)
const title = '助学转出'
const $ = sys.$(title)

sys.run($, 'task:one', (resList, cookie, index, username, password, item) => {
    return new Promise(async resolve => {

        // 请求接口
        const cacheNum = -1
        const inResp = await $.publicJS.outAmount($, cookie, cacheNum)
        // 追加信息
        resList.push({
            "序号": index + 1,
            username,
            inResp
        })
        resolve(resList)
    })
}, (resList) => {
    console.log('任务结束 resList:', resList)
    if (resList && resList.length > 0) {
        resList = resList.sort((a1, a2) => {
            return a1['序号'] - a2['序号']
        })
        const resListStr = JSON.stringify(resList, null, 2)
        $.notify.sendNotify(title, resListStr)
    }
})
